package com.boxuegu.myapplication.utils;

import java.security.MessageDigest;

public class MD5Utils {
    public static String md5(String text){
        try{
            MessageDigest messageDigest=MessageDigest.getInstance("md5");
            byte[] result= messageDigest.digest(text.getBytes());
            String str="";
                    for (byte b:result){
                        int number=b&0xff;
                        String hex=Integer.toHexString(number);
                        if (hex.length()==1){
                            hex="0"+hex;
                        }
                        str=str+hex;
                    }
                    return str;
        }catch (Exception e){
            e.printStackTrace();
            return "";
        }

    }
}
